#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import math
from aber import AberResFile

res = AberResFile("rv")

M  = res.getMagnification()
So = res.getSourceSize()
Cs = res.getSphericalAber() / 1000.
Ai = res.getAi()
Cc = res.getChromaticAB() * 1000.
Dv = res.getBeamVoltageRipple()
Vi = res.getBeamVoltageAtImage()
Lambda = res.getLambda()

Dg = M*So
Ds = 0.5*Cs*Ai*Ai*Ai
Dc = 0.5*Cc*Ai*Dv/Vi
Dd = 0.75*1.22*Lambda/Ai
D = math.sqrt(Dg*Dg+Ds*Ds+Dc*Dc+Dd*Dd)

print Dg, Ds, Dc, Dd
print D, res.getBeamSpotDiameter()

raw_input("press Enter key to exit...")
